package cn.majingjing.tm.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class HelloController {

	@Autowired
	RestTemplate restTemplate;

	@RequestMapping(value = "/hello", method = RequestMethod.GET)
	public String hello(@RequestParam(name = "name", defaultValue = "皇太极") String name) {
		return "ribbon ---> " + restTemplate.getForObject("http://SERVICE/hello?name=" + name, String.class);
	}

	@RequestMapping("/test1")
	public String test1(@RequestParam(name = "name", defaultValue = "皇太极") String name) {
		return "ribbon ---> " + restTemplate.getForObject("http://SERVICE/test1?name=" + name, String.class);
	}
	
	@RequestMapping("/test2")
	public String test2(@RequestParam(name = "name", defaultValue = "皇太极") String name) {
		return "ribbon ---> " + restTemplate.getForObject("http://SERVICE-FEIGN/test2?name=" + name, String.class);
	}
	
}
